package model

import "kpt-dtm/model/yyn"

type MixData struct {
	Id         int64  `json:"id"`
	PastureId  int64  `json:"pasture_id"`
	ElabLoadId int    `gorm:"column:elabLoad_id" json:"elabLoad_id"`
	LoadDate   string `json:"load_date"`
	TmrNo      string `json:"tmr_no"`
	RecipeId   string `json:"recipe_id"`
	CreatedAt  int64  `json:"created_at"`
	UpdatedAt  int64  `json:"updated_at"`
}

func (m *MixData) TableName() string {
	return "d_mix"
}

func NewMix(pastureId int64, loadDate, tmrNo, recipeId string, elabLoadId int) *MixData {
	return &MixData{
		PastureId:  pastureId,
		LoadDate:   loadDate,
		TmrNo:      tmrNo,
		RecipeId:   recipeId,
		ElabLoadId: elabLoadId,
	}
}

func NewMixDataList(pastureId int64, res []*yyn.MixData) []*MixData {
	mixList := make([]*MixData, 0)
	for _, v := range res {
		mixList = append(mixList, NewMix(pastureId, v.LoadDate, v.TmrNo, v.RecipeId, v.ElabLoadId))
	}
	return mixList
}
